package exo1;

import exo1.Point;

public class Segment extends Forme implements Checked {

	private Point origine;
	private Point finale;
	public Segment(Point origine, Point finale) {
		super();
		this.origine = origine;
		this.finale = finale;
		invariant();
	}
	public Point getOrigine() {
		return origine;
	}
	public void setOrigine(Point origine) {
		this.origine = origine;
		invariant();
	}
	public Point getFinale() {
		return finale;
	}
	public void setFinale(Point finale) {
		this.finale = finale;
		invariant();
	}
	@Override
	public void dessiner(PileTransformations p){
		String s="Segment [origine=" + origine + ", finale=" + finale + "]\n";
		s+="-----";
		Point point=p.depiler();
			s+=" "+point;
		s+="-----";
		System.out.println(s);
	}
	@Override
	public void  deplacer(Point point){
		invariant();
		origine=origine.additioner(point);
		finale=finale.additioner(point);
		invariant();
	}
	@Override
	public String toString() {
		return "Segment [origine=" + origine + ", finale=" + finale + "]";
	}
	@Override
	public void invariant() {
		assert !origine.equals(finale):"Le point de d�part est �gal point d'arriv�e:Segment";
		
	}
	
}
